﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Patent.CN;
using Patent;
using System.Data;
using DevExpress.XtraCharts;

public partial class China_Chart_ChineseApplicantPatentCountChart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Prevent IE Cache
        Response.Expires = 0;

        if (!IsPostBack)
        {
            //int topicID = 1;
            int topicID = Convert.ToInt32(Session["topicID"].ToString());

            ChinaAnalysis cnAnalysis = new ChinaAnalysis(topicID);

            if (cnAnalysis.IsChineseTopic())
            {
                if (Request["applicants"] != null)
                {
                    string[] applicants = Server.UrlDecode(Request["applicants"]).Split('|');
                    DataTable dt = cnAnalysis.GetApplicantSumTable(applicants);
                    if (dt == null)
                    {
                        Response.End();
                        return;
                    }

                    WebChartCN.Series.Clear();
                    
                    Series syxxSeries = new Series("实用新型", ViewType.Bar);
                    Series fmzlSeries = new Series("发明专利", ViewType.Bar);
                    Series wgsjSeries = new Series("外观设计", ViewType.Bar);
                    Series totalSeries = new Series("总计", ViewType.Bar);

                    syxxSeries.ArgumentDataMember = "标志";
                    syxxSeries.ValueDataMembers.AddRange(new string[] { "实用新型" });

                    fmzlSeries.ArgumentDataMember = "标志";
                    fmzlSeries.ValueDataMembers.AddRange(new string[] { "发明专利" });

                    wgsjSeries.ArgumentDataMember = "标志";
                    wgsjSeries.ValueDataMembers.AddRange(new string[] { "外观设计" });

                    totalSeries.ArgumentDataMember = "标志";
                    totalSeries.ValueDataMembers.AddRange(new string[] { "总计" });
                    WebChartCN.Series.Add(totalSeries);
                    
                    WebChartCN.Series.Add(fmzlSeries);
                    WebChartCN.Series.Add(syxxSeries);
                    WebChartCN.Series.Add(wgsjSeries);
                   
                    foreach (Series series in WebChartCN.Series)
                    {
                        series.Label.Visible = false;
                        series.DataSource = dt;
                        series.ArgumentScaleType = ScaleType.Qualitative;
                        series.ValueScaleType = ScaleType.Numerical;
                    }
                }
                else
                {
                    Response.End();
                }
            }
            else
            {
                Response.End();
            }
        }
    }
}
